package Study.company;

import java.util.Scanner;

public class Practice04 {
    public static void main(String[] args) {
        //给定一个整数数组，输入位置 n 和值 k。将值 k 插入到数组的第 n 位并输出新数组的每一个元素。
        int[] arr = {2, 3, 1, 8, 3, 9, 6};
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入n值：");
        int n = sc.nextInt();
        System.out.println("请输入k值：");
        int k = sc.nextInt();
        int[] num = new int[arr.length +1];
        for (int i = 0; i < num.length ; i++) {
            if (n  == i ){
                for (int j = i ; j <num.length - 1 ; j++) {
                    num[j + 1] = arr[j];
                }
                num[n] = k;
                break;
            }
            else {
                num[i] = arr[i];
            }
        }
        for (int i: num
             ) {
            System.out.print(i + "\t");
        }
    }
}
